/**
* 比赛-未登录弹窗组件，使用： this.$store.dispatch('setModal',{visible:true，modalId:'modlaId'}); 注意this指向的上下文环境，有时候是写self或其它
*/
<template>
  <transition name="slide-fade">
    <div v-if="modal.visible && modal.modalId=='gameNotLoginModal'" class="modal" id="gameNotLoginModal" tabindex="-1" @click.stop.prevent="modalHide">
      <div class="modal-dialog" @click.stop.prevent>
        <div class="modal-content">
          <img src="~assets/images/tankuang.png" class="img-responsive">
          <img src="~assets/images/close@2x.png" data-dismiss="modal" class="img-close" @click.stop.prevent="modalHide">
          <div class="oxhead">
            <img src="https://dl.app.gtja.com/nrng/shareimages/oxhead/niugaoxing.png">
          </div>
          <div class="wrapper">
            <h4>艾玛，参赛用户的持仓只有<span>注册用户</span>才能看哦</h4>
            <button type="button" class="btn btn-lg btn-agree" @click.stop.prevent="toLogin">注册去</button>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
  import BaseModal from 'components/modal/BaseModal'
  import RemoteDAO from 'common/remoteDAO'
  import LocalDAO from 'common/localDAO'
  import CommonUtil from 'common/common.util'

  export default {
    data () {
      return {}
    },
    extends:BaseModal,
    methods:{
      toLogin(){
        RemoteDAO.callNativeLogin(function(response) {
          if (Number(response.error) === 0) {

            // 更新个人信息，尤其是 walletTotal，订阅牛人弹窗需要展示
            var userCode = LocalDAO.getUserCode();
            RemoteDAO.callUC12000104(userCode, function(response) {
              if (response.error == "0") {
                var userHead = response.data.body[0].USER_HEAD;
                var walletTotal = CommonUtil.toFixed(response.data.body[0].WALLET_TOTAL, 0);
                var goodpointCount = response.data.body[0].GOODPOINT_COUNT;
                var subscribeUserCount = response.data.body[0].SUBSCRIBE_USER_COUNT; // 被订阅数
                var subscribePrice = CommonUtil.toFixed(response.data.body[0].SUBSCRIBE_PRICE, 0);

                if (subscribePrice == "") {
                  subscribePrice = "0";
                }

                // 跟新本地缓存
                if (userHead != "") {
                  LocalDAO.setUserHead(userHead);
                }
                LocalDAO.setWalletTotal(walletTotal);
                LocalDAO.setGoodpointCount(goodpointCount);
                LocalDAO.setSubscribeUserCount(subscribeUserCount);
                LocalDAO.setSubscribePrice(subscribePrice);
              }
            });

            window.location.reload(true);
          }
        });
      }
    }
  }
</script>

<style scoped>
  .slide-fade-enter-active,.slide-fade-leave-active{
    transition: all 0.3s ease;
  }
  .slide-fade-enter, .slide-fade-leave-active {
    transform: translate(0,-25%);
    opacity: 0;
  }
</style>
